package com.eu.ebpm.engine.cmd.pvm;

import java.util.Date;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.eu.ebpm.engine.entity.deploy.Mission;
import com.eu.ebpm.engine.entity.deploy.Transfer;
import com.eu.ebpm.engine.entity.history.HisTask;
import com.eu.ebpm.engine.entity.runtime.TaskEntity;
import com.eu.ebpm.engine.repository.HisTaskRepository;

/**
 * 
 * @author wxh
 */
@Component
public class ForkBeforeIntoCommand {

	@Autowired
	private HisTaskRepository hisTaskRepository;
	
	public void execute(Mission m, TaskEntity task, Map<String, Object> variables) {
		
		String transferName = "";
		
		for(Transfer t : m.getTransfers()) {
			transferName = transferName + t.getName() + ",";
		}
		
		HisTask hisTask = new HisTask(m.getType(), m.getName(), m.getDesc(), transferName, task.getExecutionId(), task.getRootExecutionId(), m.getId(), null, null, new Date(), new Date());
		
		hisTaskRepository.insert(hisTask);
		
	}
	
	
	
	
	

}
